<template>
  <div class="wrapper">
    <!-- 头部区域 -->
    <div class="title-wrapper">
      <div class="title">男女比例</div>
      <img class="title-icon" src="../images/dataScreen-title.png" />
    </div>
    <div class="content-wrapper">
      <div class="bg-wrapper">
        <div class="gender man">
          <div class="lable">男士</div>
          <img src="../images/man.png">
        </div>
        <div class="gender girl">
          <div class="lable">女士</div>
          <img src="../images/woman.png">
        </div>
      </div>
      <div class="font-wrapper">
        <div class="font">男士60%</div>
        <div class="font">女士40%</div>
      </div>
      <div class="echart" ref="genderRef"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts';
let genderRef = ref()

onMounted(()=>{
  genderEcharts()
})
const genderEcharts = ()=>{
   const chart = echarts.init(genderRef.value)
  const option = {
    xAxis: {
      show: false,
    },
    yAxis: {
      show: false,
      type: "category",

    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: '#0074fc',
          borderRadius: 20,
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: '-100%',
        itemStyle: {
          color: '#fe5f73',
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  }
   chart.setOption(option)
}
</script>

<style scoped lang="scss">
.wrapper{
  margin-top: 24px;
  width: 100%;
  height: 300px;
  background: url(../images/dataScreen-main-lc.png) no-repeat;
  background-size: cover;
  .title-wrapper{
    padding-left:10px;
    .title{
       color: white;
          font-size: 20px;
          margin-bottom: 2px;
    }
    .title-icon {
          width: 50px;
        }
  }
  .content-wrapper{
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50px;
    .bg-wrapper{
      display:flex;
      .gender{
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 110px;
        height: 110px;
        img{
          width: 50px;
          height: 50px;
        }
        .lable{
          color: white;
          text-align: center;
          padding-left: 10px;
          margin-top: 2px;
          margin-bottom: 16px;
        }
      }
      .man{
        background: url(../images/man-bg.png) no-repeat;
        background-size: cover;
        margin-right: 60px;

      }
      .girl{
        background: url(../images/woman-bg.png) no-repeat;
        background-size: cover;
      }
    } 
    .font-wrapper{
      width: 300px;
      display: flex;
      justify-content: space-between;
      margin-top: 26px;
      margin-bottom: -30px;
      .font{
        color: white;
      }
    }
    .echart{
      width: 300px;
      height: 100px;
      // background: #bfc;
    }
  }
}
</style>
